<?php
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();

$eventid	= intval($_POST['eventid']);
$content	= tsClean($_POST['content']);

$text = strip_tags($_POST['content'],'<img>');

if($text == ''){
	tsNotice('评论内容不能为空');
}

if($TS_USER['isadmin']==0){
	//过滤内容开始
	aac('system')->antiWord($content);
	//过滤内容结束
}

$commentid = $new['event']->create('event_comment',array(
	'eventid'			=> $eventid,
	'userid'			=> $userid,
	'content'	=> $content,
	'addtime'		=> time(),
));

$strEvent = $new['event']->getEventByEventid($eventid);
if($strEvent['userid'] != $TS_USER['userid']){
	$msg_userid = '0';
	$msg_touserid = $strEvent['userid'];
	$msg_content = '你的活动《'.$strEvent['title'].'》新增一条评论，快去看看吧^_^ ';
	$msg_tourl = tsUrl('event','show',array('id'=>$eventid));
	aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);

}

$content = '评论了活动《<a href="'.tsUrl('event','show',array('id'=>$eventid)).'">'.$strEvent['title'].'》！</a>';
aac('weibo')->create('weibo',array(
	'userid'=>$TS_USER['userid'],
	'content'=>$content,
	'isaudit'=>0,
	'addtime'=>date('Y-m-d H:i:s'),
	'uptime'=>date('Y-m-d H:i:s'),
));

header("Location: ".tsUrl('event','show',array('id'=>$eventid)));